/**
* File: MovableText.h
*
* description: This create create a billboarding object that display a text.
* 
* @author  2003 by cTh see gavocanov@rambler.ru
* @update  2006 by barraq see nospam@barraquand.com
*/
 
#ifndef __include_MovableTex_H__
#define __include_MovableTex_H__
 
namespace Ogre {
 
class MovableTexture : public MovableObject, public Renderable
{
    /******************************** MovableText data ****************************/
public:
    enum HorizontalAlignment    {H_LEFT, H_CENTER};
    enum VerticalAlignment      {V_BELOW, V_ABOVE, V_CENTER};
 
protected:
    String			mType;
    String			mName;
	String			mFileName;

    HorizontalAlignment    mHorizontalAlignment;
    VerticalAlignment    mVerticalAlignment;
 
    ColourValue			mColor;
    RenderOperation		mRenderOp;
    AxisAlignedBox		mAABB;
    LightList			mLList;
  
    bool			 mNeedUpdate;
    bool			mUpdateColors;
    bool			mOnTop;
	bool			mbAutoScale;
 
    Real			mTimeUntilNextToggle;
    Real			mRadius;
	Real			mScaleK;
 
    Vector3			mGlobalTranslation;
    Vector3			mLocalTranslation;

	float			mHeight;
	float			mWidth;
	float			mOffsetX;
 
    Camera            *mpCam;
    RenderWindow    *mpWin;
    MaterialPtr        mpMaterial;
    MaterialPtr        mpBackgroundMaterial;
 
    /******************************** public methods ******************************/
public:
	MovableTexture(const String &name, const String &fileName
		, float height, float width
		, float offsetX = 0.f
		, const ColourValue &color = ColourValue::White );
    virtual ~MovableTexture();
 
    // Add to build on Shoggoth:
    virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false);
 
    // Set settings
    void    setColor(const ColourValue &color);
    void    setGlobalTranslation( Vector3 trans );
    void    setLocalTranslation( Vector3 trans );
    void    showOnTop(bool show=true);
	void	setAdditionalHeight( float height = 0.f );
	void	setPlaneSize( float height, float width );
	void	setTexName( const String &fileName );
	void	setAutoScale( bool bAutoscle, float AutoscaleK = 0.2f );
 
    // Get settings
    const   ColourValue     &getColor() const {return mColor;}
 
    Vector3		getGlobalTranslation() const {return mGlobalTranslation;}
    Vector3		getLocalTranslation() const {return mLocalTranslation;}
    bool		getShowOnTop() const {return mOnTop;}
    AxisAlignedBox            GetAABB(void) { return mAABB; }
	String		getMyName(){ return mName; }
 
    /******************************** protected methods and overload **************/
protected:
 
    // from MovableText, create the object
    void    _setupGeometry();
	void    _setupGeometryTest();
    void    _updateColors();
 
    // from MovableObject
    void    getWorldTransforms(Matrix4 *xform) const;
    Real    getBoundingRadius(void) const {return mRadius;};
    Real    getSquaredViewDepth(const Camera *cam) const {return 0;};
    const   Quaternion        &getWorldOrientation(void) const;
    const   Vector3           &getWorldPosition(void) const;
    const   AxisAlignedBox    &getBoundingBox(void) const {return mAABB;};
    const   String            &getName(void) const {return mName;};
    const   String            &getMovableType(void) const {static Ogre::String movType = "MovableText"; return movType;};
 
    void    _notifyCurrentCamera(Camera *cam);
    void    _updateRenderQueue(RenderQueue* queue);
 
    // from renderable
    void    getRenderOperation(RenderOperation &op);
    const   MaterialPtr       &getMaterial(void) const {assert(!mpMaterial.isNull());return mpMaterial;};
    const   LightList         &getLights(void) const {return mLList;};
};
 
} //end namespace Ogre
 
#endif